<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>创客英雄</title>
    <script src="http://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
    <link href="__TMPL__Portal/assets/css/ckyx.css" rel="stylesheet">
    <script src="__TMPL__Portal/assets/js/ckyx.min.js"></script>
    <link href="__TMPL__Portal/assets/css/main.css" rel="stylesheet">
    <script src="__PUBLIC__/js/layer/layer.js"></script>
</head>

<body>
<!--header-->
<tc_include file="head"/>
<div class="nav_box">
    <div class="container">
        <div class="row">
            <a class="logo col-md-2" href="index.html">
                <img src="__TMPL__Portal/assets/images/logo.png">
            </a>
            <tc_include file="nav"/>
        </div>
    </div>
</div>

<!--banner_2-->
<div class="container banner_2">
    <img src="__TMPL__Portal/assets/images/zsxc.png">
</div>

<!--main3-->
<div class="container main3_box">
    <div class="ysbkbt">
        <div>忘记密码</div>
    </div>
    <div class="main1_left main3 main5">
        <div class="twbk">
            <div class="dlkj">
                <div class="dlkjnr">
                    <div class="input-group youxiang">
                        <input type="text" class="form-control" placeholder="请输入注册邮箱" id="email">
                    </div>
                    <div class="input-group mima qsryzm">
                        <input type="text" class="form-control" placeholder="请输入验证码" id="j_verify">
                        <div><img src="{:U('hacker/verify')}" id="verify_img"></div>
                        <a href="javascript:void(0);" id="changeImg">换一张</a>
                    </div>
                    <div class="btn-group denglu">
                        <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"
                                onClick="changePsw();">
                            发送验证邮件
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var isVerifyOK = false;
    $("#changeImg").click(function () {
        var verifyURL = "hacker/verify";
        var time = new Date().getTime();
        $("#verify_img").attr({
            "src": verifyURL + "/" + time
        });
    });
    $("#j_verify").keyup(function () {
        $.post("hacker/check_verify", {
            code: $("#j_verify").val()
        }, function (data) {
            var result = eval("(" + data + ")");
            if (result.status) {
                isVerifyOK = true;
            } else {
                isVerifyOK = false;
            }
        });
    });
    function changePsw() {

        var email = $.trim($("#email").val());
        if (email == "") {
            layer.msg('请输入邮箱');
            return false;
        }
        // 邮箱验证正则表达式
        var pattern = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
        if (!pattern.test(email)) {
            layer.msg('邮箱格式不正确');
            return false;
        }

        if (!isVerifyOK) {
            layer.msg('验证码不正确');
            return false;
        }

        $.ajax({
            type: "POST",
            url: "{:U('Hacker/sendEmail')}",
            data: {email: email},
            success: function (result) {
                var result = eval("(" + result + ")");
                if (result.status) {
                    location.href = "__ROOT__/Portal/Hacker/yjfs?email=" + email;
                } else {
                    layer.msg(result.message);
                }
            }
        });
    }
</script>

<!--页脚-->
<tc_include file="footer"/>


</body>
</html>
